const hapi = require('hapi')
const server = new hapi.Server()
require('env2')('./.env')
const Config = require('./config/index')
const Route = require('./routes/hello-world')
// 通过env2来读取.env的配置文件
// 配置服务器启动与端口
server.connection({
  host: Config.host,
  port: Config.port
})

const init = async () => {
  await server.route([
    ...Route
  ]);
  // 启动服务
  await server.start();
  console.log(`server running at: ${server.info.uri}`)
}

init()
